{% if paginator %}
    {% for post in paginator.posts %}
        {% include post_list_item.html %}
    {% endfor %}
{% else %}
    {% for post in include.posts %}
        {% if post.tags or post.category %}
            {% include post_list_item.html %}
            {% assign displayPagi = true %}
        {% endif %}
    {% endfor %}
{% endif %}

{% if displayPagi or paginator %}
<div class="row" id="paginator">
    {% if paginator.total_pages > 1 %}
        {% if paginator.previous_page %}
            <a href="{{ paginator.previous_page_path | relative_url }}">«</a>
        {% endif %}

        {% for page in (1..paginator.total_pages) %}
            {% if page == paginator.page %}
                <span class="active">{{ page }}</span>
            {% elsif page == 1 %}
                <a href="{{ '/' | relative_url }}">{{ page }}</a>
            {% else %}
                <a href="{{ site.paginate_path | replace: ':num', page | relative_url }}">{{ page }}</a>
            {% endif %}
        {% endfor %}

        {% if paginator.next_page %}
            <a href="{{ paginator.next_page_path | relative_url }}">»</a>
        {% endif %}
    {% elsif jsPagiLoaded != true %}
        <script type="text/javascript" src="{{ '/assets/js/pagination.js' | relative_url }}"></script>
        <script type="text/javascript" src="{{ '/assets/js/list_pagi.js' | relative_url }}"></script>
        {% assign jsPagiLoaded = true %}
    {% endif %}

</div>
{% endif %}
{% assign displayPagi = false %}